home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / intuition / closescreen.c < prev    next >
C/C++ Source or Header  |  1996-10-31  |  2KB  |  111 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: closescreen.c,v 1.3 1996/10/31 13:50:39 aros Exp $
  4.     $Log: closescreen.c,v $
  5.     Revision 1.3  1996/10/31 13:50:39  aros
  6.     Don't forget to free the RastPort
  7.  
  8.     Revision 1.2  1996/10/24 15:51:18  aros
  9.     Use the official AROS macros over the __AROS versions.
  10.  
  11.     Revision 1.1  1996/09/21 14:11:39  digulla
  12.     Open and close screens
  13.  
  14.  
  15.     Desc:
  16.     Lang: english
  17. */
  18. #include "intuition_intern.h"
  19. #include <clib/exec_protos.h>
  20. #include <clib/graphics_protos.h>
  21.  
  22. #ifndef DEBUG_CloseScreen
  23. #   define DEBUG_CloseScreen 0
  24. #endif
  25. #if DEBUG_CloseScreen
  26. #   undef DEBUG
  27. #   define DEBUG 1
  28. #endif
  29. #include <aros/debug.h>
  30.  
  31. /*****************************************************************************
  32.  
  33.     NAME */
  34.     #include <intuition/screens.h>
  35.     #include <clib/intuition_protos.h>
  36.  
  37.     AROS_LH1(BOOL, CloseScreen,
  38.  
  39. /*  SYNOPSIS */
  40.     AROS_LHA(struct Screen *, screen, A0),
  41.  
  42. /*  LOCATION */
  43.     struct IntuitionBase *, IntuitionBase, 11, Intuition)
  44.  
  45. /*  FUNCTION
  46.  
  47.     INPUTS
  48.  
  49.     RESULT
  50.  
  51.     NOTES
  52.  
  53.     EXAMPLE
  54.  
  55.     BUGS
  56.  
  57.     SEE ALSO
  58.  
  59.     INTERNALS
  60.  
  61.     HISTORY
  62.     29-10-95    digulla automatically created from
  63.                 intuition_lib.fd and clib/intuition_protos.h
  64.  
  65. *****************************************************************************/
  66. {
  67.     AROS_LIBFUNC_INIT
  68.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  69.     struct Screen * parent;
  70.  
  71.     D(bug("CloseScreen (%p)\n", screen));
  72.  
  73.     /* Trick: Since NextScreen is the first field of the structure,
  74.     we can use the pointer in the IntuitionBase as a screen with
  75.     the structure-size of one pointer */
  76.     parent = (struct Screen *)&(IntuitionBase->FirstScreen);
  77.  
  78.     /* For all screens... */
  79.     while (parent->NextScreen)
  80.     {
  81.     /* If the screen to close is the next screen... */
  82.     if (parent->NextScreen == screen)
  83.     {
  84.         /* Unlink it */
  85.         parent->NextScreen = screen->NextScreen;
  86.  
  87.         /* Check ActiveScreen */
  88.         if (IntuitionBase->ActiveScreen == screen)
  89.         {
  90.         if (screen->NextScreen)
  91.             IntuitionBase->ActiveScreen = screen->NextScreen;
  92.         else if (IntuitionBase->FirstScreen)
  93.             IntuitionBase->ActiveScreen = parent;
  94.         else
  95.             IntuitionBase->ActiveScreen = NULL;
  96.         }
  97.  
  98.         /* Free the RastPort's contents */
  99.         DeinitRastPort (&screen->RastPort);
  100.  
  101.         /* Free the memory */
  102.         FreeMem (screen, sizeof (struct Screen));
  103.  
  104.         ReturnBool("CloseScreen",TRUE);
  105.     }
  106.     }
  107.  
  108.     ReturnBool("CloseScreen",FALSE);
  109.     AROS_LIBFUNC_EXIT
  110. } /* CloseScreen */
  111.